#pragma once

struct Command
{
	virtual void Invoke() = 0;
};

template <class T>
class Command0 : public Command
{
	T *_pT;
	void (T::*_pfn) ();

	// TODO: Rather than pointer-to-member, could I use a std::tr1::function in here?
	// In fact, could I use a std::tr1::function instead of a command, anyway?
public:
	Command0(T *pT, void (T::*pfn) ()) : _pT(pT), _pfn(pfn) { }
	virtual void Invoke() { (_pT->*_pfn)(); }
};

template <class T, typename A0>
class Command1 : public Command
{
	T *_pT;
	void (T::*_pfn) (A0 a0);
	A0 _a0;

public:
	Command1(T *pT, void (T::*pfn) (A0), A0 a0)
		: _pT(pT), _pfn(pfn), _a0(a0)
	{
	}

	virtual void Invoke() { (_pT->*_pfn)(_a0); }
};

template <class T, typename A0, typename A1, typename A2>
class Command3 : public Command
{
	T *_pT;
	void (T::*_pfn) (A0 a0, A1 a1, A2 a2);
	A0 _a0;
	A1 _a1;
	A2 _a2;

public:
	Command3(T *pT, void (T::*pfn) (A0, A1, A2), A0 a0, A1 a1, A2 a2)
		: _pT(pT), _pfn(pfn), _a0(a0), _a1(a1), _a2(a2)
	{
	}

	virtual void Invoke() { (_pT->*_pfn)(_a0, _a1, _a2); }
};
